package Package.Example_5;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Example_5 {
    public static void Example_5() throws IOException {
        ServerSocket ss=new ServerSocket(10086);
        Socket s = ss.accept();
        BufferedWriter bw=new BufferedWriter(new FileWriter("D:\\insert\\Example_2.txt"));
        BufferedReader br=new BufferedReader(new InputStreamReader(s.getInputStream()));
        String line;
        while ((line=br.readLine())!=null){
            bw.write(line);
            bw.newLine();
            bw.flush();
        }

        BufferedWriter bws=new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
        bws.write("传输成功");
        bws.newLine();
        bws.flush();
        bw.close();
        ss.close();
    }
}
